
package de.godlike.android.web;

import org.ksoap2.SoapFault;

import android.util.Log;

public class JWebminService {

    private final int serverId;

    private KsoapWrapper soap;

    private final String EXCEPTION_STRING = "Unkown";

    private final String LOG_TAG = this.getClass().toString();

    private JWebminService() {
        this.serverId = 0;
    }

    public JWebminService(int serverId, String serverUrl) {
        this.serverId = serverId;
        this.soap = new KsoapWrapper(serverUrl);
    }

    public int getServerId() {
        return serverId;
    }

    /*
     * Readonly Service Methods
     */
    public String getOsType() {
        try {
            return (String) soap.callMethod("getOsType").getResponse().toString();
        } catch (SoapFault e) {
            Log.e(LOG_TAG, e.getMessage());
            return this.EXCEPTION_STRING;
        }
    }

    public String getArch() {
        try {
            return (String) soap.callMethod("getArch").getResponse().toString();
        } catch (SoapFault e) {
            Log.e(LOG_TAG, e.getMessage());
            return this.EXCEPTION_STRING;
        }
    }

    public String getOsVersion() {
        try {
            return (String) soap.callMethod("getOsVersion").getResponse().toString();
        } catch (SoapFault e) {
            Log.e(LOG_TAG, e.getMessage());
            return this.EXCEPTION_STRING;
        }
    }

    public String getTimeZone() {
        try {
            return (String) soap.callMethod("getTimeZone").getResponse().toString();
        } catch (SoapFault e) {
            Log.e(LOG_TAG, e.getMessage());
            return this.EXCEPTION_STRING;
        }
    }

    public String getSystemName() {
        try {
            return (String) soap.callMethod("getSystemName").getResponse().toString();
        } catch (SoapFault e) {
            Log.e(LOG_TAG, e.getMessage());
            return this.EXCEPTION_STRING;
        }
    }

    public String getSystemIp() {
        try {
            return (String) soap.callMethod("getSystemIp").getResponse().toString();
        } catch (SoapFault e) {
            Log.e(LOG_TAG, e.getMessage());
            return this.EXCEPTION_STRING;
        }
    }

    /*
     * ReadWrite Service Methods
     */

}
